package com.daiyang.book_boot.controller;

import com.daiyang.book_boot.model.Book;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@Controller
@RequestMapping("/book")
public class getBookList {
    @PostMapping("/getBookList")
    public List<Book>getList () {
        List<Book> list = new ArrayList<Book>();
        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            Book book = new Book();
            book.setId(i+"");
            book.setName("大唐帝国第"+i+"卷");
            book.setCount("" + random.doubles(100));
            book.setPrice("" + random.doubles(50));
            book.setPublisher("出版社"+i+"号");
            if (i%2==0) {
                book.setState("可借阅");
            } else {
                book.setState("不可借阅");
            }

        }
        return  list;
    }

}
